package xuegao.study.mall.admin.feign;

import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.common.api.CommonPage;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.domain.UserDto;
import xuegao.study.mall.common.dto.rbac.UmsAdminRegisterDto;
import xuegao.study.mall.common.model.ums.UmsAdmin;
import xuegao.study.mall.common.model.ums.UmsRole;
import java.util.List;

@FeignClient(contextId = "admin", name = "study-rbac-service", path = "/rbac/admin")
public interface UmsAdminClient {

    @PostMapping("/register")
    CommonResult<Integer> register(@RequestBody UmsAdminRegisterDto registerDto);

    @ApiOperation("删除用户")
    @PostMapping("/delete/{id}")
    CommonResult<Integer> deleteAdmin(@PathVariable("id") Long id);

    @ApiOperation("更新用户状态")
    @PostMapping(value = "/updateStatus/{adminId}")
    CommonResult updateAdminStatus(@PathVariable("adminId") Long adminId, @RequestParam("status") Integer status);

    @ApiOperation("更新用户信息")
    @PostMapping("/update/{id}")
    CommonResult<Integer> update(@PathVariable("id") Long id, @RequestBody UmsAdmin umsAdmin);

    @ApiOperation("获取用户列表")
    @GetMapping("/list")
    CommonResult<CommonPage<UmsAdmin>> listAdmin(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(value = "name", defaultValue = "") String name);

    @ApiOperation("获取用户-角色列表")
    @GetMapping("/role/{adminId}")
    CommonResult<List<UmsRole>> adminRoles(@PathVariable("adminId") Long adminId);

    @ApiOperation("更新用户-分配角色")
    @PostMapping("/role/update")
    CommonResult<Integer> allocRoles(@RequestParam Long adminId, @RequestParam List<Long> roleIds);

    @ApiOperation("根据用户名获取通用用户信息")
    @GetMapping(value = "/loadByUsername")
    UserDto loadUserByUsername(@RequestParam String username);

    @ApiOperation(value = "获取当前登录用户信息")
    @GetMapping("/info")
    CommonResult getAdminInfo(@RequestParam String userStr);

    @ApiOperation("记录用户登录日志")
    @PostMapping("/log")
    CommonResult log(@RequestParam String username);
}
